/* Turska UI library
 * Copyright 2003-2008 Jetro Lauha
 * All rights reserved.
 * Web: http://iki.fi/jetro/
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of EITHER:
 *   (1) The GNU Lesser General Public License as published by the Free
 *       Software Foundation; either version 2.1 of the License, or (at
 *       your option) any later version. The text of the GNU Lesser
 *       General Public License is included with this library in the
 *       file LICENSE-LGPL.txt.
 *   (2) The BSD-style license that is included with this library in
 *       the file LICENSE-BSD.txt.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the files
 * LICENSE-LGPL.txt and LICENSE-BSD.txt for more details.
 *
 * $Id: UIComponent.h,v 1.2 2008/03/27 11:44:22 tonic Exp $
 * $Revision: 1.2 $
 */

#ifndef UICOMPONENT_H_INCLUDED
#define UICOMPONENT_H_INCLUDED


class UIComponent
{
public:

    UIComponent(INT x, INT y, INT width, INT height);
    virtual ~UIComponent() {}

    virtual void setX(INT x) { mX = x; }
    virtual void setY(INT y) { mY = y; }
    virtual void setWidth(INT width) { mWidth = width; }
    virtual void setHeight(INT height) { mHeight = height; }
    virtual INT getX() { return mX; }
    virtual INT getY() { return mY; }
    virtual INT getWidth() { return mWidth; }
    virtual INT getHeight() { return mHeight; }
    virtual bool isInside(INT x, INT y);
    virtual bool isPointerDown() { return mIsPointerDown; }

    virtual void addEventListener(UIEventListener *eventListener);
    virtual void removeEventListener(UIEventListener *eventListener);
    virtual void removeAllEventListeners();

    virtual void onPointerDown(INT x, INT y);
    virtual void onPointerUp(INT x, INT y);
    virtual void onPointerMove(INT x, INT y);

    virtual void draw() {}

    void setImageDrawMode(UINT drawMode) { mImageDrawMode = drawMode; }
    void setImageFlags(UINT32 imageFlags) { mImageFlags = imageFlags; }
    UINT getImageDrawMode() { return mImageDrawMode; }
    UINT32 getImageFlags() { return mImageFlags; }

protected:

    typedef std::set<UIEventListener *> EventListenerSet;
    INT mX, mY;
    INT mWidth, mHeight;
    UINT mImageDrawMode;
    UINT32 mImageFlags;
    BOOL mIsPointerDown;

    EventListenerSet mEventListeners;
};


#endif // !UICOMPONENT_H_INCLUDED
